package com.app.beu.core.renderer;

import tsm.model.Buddy;

import com.core.tsm.Button;
import com.core.tsm.CheckBox;
import com.core.tsm.Component;
import com.core.tsm.Label;
import com.core.tsm.List;
import com.core.tsm.list.ListCellRenderer;

public class InviteListRenderer extends CheckBox implements ListCellRenderer {
	private CheckBox checkboxBuddy;
	private Label labelSelected;

	public InviteListRenderer() {
		super("");
		setUIID("ListRenderer");
		labelSelected = new Label();
		labelSelected.getSelectedStyle().setPadding(Button.TOP, 0);
		labelSelected.getSelectedStyle().setMargin(Button.TOP, 0);
		labelSelected.getSelectedStyle().setPadding(Button.BOTTOM, 1);
		labelSelected.getSelectedStyle().setMargin(Button.BOTTOM, 1);
		labelSelected.getSelectedStyle().setPadding(Button.LEFT, 0);
		labelSelected.getSelectedStyle().setMargin(Button.LEFT, 0);
		labelSelected.getSelectedStyle().setPadding(Button.RIGHT, 0);
		labelSelected.getSelectedStyle().setMargin(Button.RIGHT, 0);
		labelSelected.getSelectedStyle().setBgColor(0x138ef6);
		labelSelected.getSelectedStyle().setBgTransparency(255);
		labelSelected.setFocus(true);

		checkboxBuddy = new CheckBox();
		checkboxBuddy.getStyle().setPadding(Button.TOP, 0);
		checkboxBuddy.getStyle().setMargin(Button.TOP, 0);
		checkboxBuddy.getStyle().setPadding(Button.BOTTOM, 1);
		checkboxBuddy.getStyle().setMargin(Button.BOTTOM, 1);
		checkboxBuddy.getStyle().setPadding(Button.LEFT, 0);
		checkboxBuddy.getStyle().setMargin(Button.LEFT, 0);
		checkboxBuddy.getStyle().setPadding(Button.RIGHT, 0);
		checkboxBuddy.getStyle().setMargin(Button.RIGHT, 0);
		checkboxBuddy.setFocus(true);
		checkboxBuddy.getStyle().setBorder(null);
		checkboxBuddy.getStyle().setBgColor(0xd2d4d3);
		checkboxBuddy.getStyle().setBgTransparency(255);
		checkboxBuddy.getStyle().setFgColor(0);
	}

	public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
		Buddy buddy = (Buddy) value;
		if (buddy.isAddConference()) {
			checkboxBuddy.setSelected(true);
		} else {
			checkboxBuddy.setSelected(false);
		}
		checkboxBuddy.setText(buddy.getUsername());
		return checkboxBuddy;
	}

	public Component getListFocusComponent(List list) {
		return labelSelected;
	}

}
